import { priority } from "utils/constants/definetypes";
import { generateUniqueId } from "utils/utils";

 

export default 
{
     
    terminal:{
        //  for(let r in Game.rooms)
        //     {
        //         if(Game.rooms[r].getType()==1)
        //         {
        //             const count = Game.rooms[r].getEntity('CoreEntity').resourceCount("GH");
        //             if(count>0)
        //             {
        //                 terminal.send(r,"E45S53","GH",Math.ceil(count*0.8));
        //             }
        //         }
        //     }
        // terminal.send("E53S44","E55S53","energy",50000)
        send(from:string,to:string,resourceType: ResourceConstant,amount:number,p:number=priority.D)
        {
            const task:ITask<ITerminalTaskData<"send">>={
                id:generateUniqueId(),
                priority:p,
                ttl:-1,
                type:"terminal",
                data:{
                    type:"send",
                    arg:{
                        From: from.trim(),
                        To: to.trim(),
                        Resource: {
                            resourceType:resourceType,
                            amount:amount
                        }
                    },
                },
                shard: 1,
            }
            Game.rooms[from].addNewTask(task);
        }
    }
}